
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
class Base():

    def __init__(self,driver):
        self.driver = driver
    def open_url(self,url):
        self.driver.get(url)
    def find_element(self,loc):

        return self.driver.find_element(*loc)

    def click(self,loc):
        self.find_element(loc).click()
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    def keys(self,loc):
        self.find_element(loc).send_keys(Keys.ENTER)
    def mouse(self,loc):
        ActionChains(self.driver).click(self.find_element(loc)).perform()
    def iframe(self,loc):
        self.driver.switch_to.frame(self.find_element(loc))
    def window(self):
        self.driver.switch_to.window(self.driver.window_handles[-1])
    def alter(self,loc):
        self.driver.switch_to.alert(self.find_element(loc))
    def select(self,loc,x):
        Select(self.find_element(loc)).select_by_index(x)
    def stea(self,x):
        self.driver.execute_script(f'window.scrollTo(0,{x})')
    def dy(self,loc):
        return self.find_element(loc).text

